.\"                                      Hey, EMACS: -*- nroff -*-
.TH RULEXDB_SUBSCRIBE_RULE 3 "February 19, 2012"
.SH NAME
rulexdb_subscribe_rule \- store a new rule into the rulex database
.SH SYNOPSIS
.nf
.B #include <rulexdb.h>
.sp
.BI "int rulexdb_subscribe_rule(RULEXDB *" rulexdb \
", const char *" src ", int " rule_type ", unsigned int " position );
.fi
.SH DESCRIPTION
The
.BR rulexdb_subscribe_rule ()
function adds a new rule to the specified ruleset in the database
referenced by
.I rulexdb
argument.
.PP
The argument
.I src
points to the text representation of the rule to be added.
.PP
The argument
.I rule_type
specifies the rule type. It may accept one of the following values:
.TP
.B RULEXDB_LEXCLASS
The rule is the word classifier and should be added to the
\fBClassifiers\fP dataset.
.TP
.B RULEXDB_PREFIX
The rule should be added to the \fBPrefix detectors\fP ruleset.
.TP
.B RULEXDB_RULE
The rule should be treated as a general rule and added to
the \fBGeneral\fP rules dataset.
.TP
.B RULEXDB_CORRECTOR
The rule is a correction rule and should be added to the
\fBCorrectors\fP dataset.
.PP
The argument
.I position
defines position of the newly added rule in the ruleset. If 0, this
rule is appended at the end of ruleset, otherwise the new rule will be
inserted at the specified position.
.SH "RETURN VALUE"
The
.BR rulexdb_subscribe_rule ()
function returns
.B RULEXDB_SUCCESS
which is zero when success or non-zero error code otherwise.
.SH ERRORS
.TP
.B RULEXDB_FAILURE
Referenced database has not been opened, internal data structures are
corrupted or some other general failure has occurred.
.TP
.B RULEXDB_EINVKEY
The argument
.I position
has a non-zero value, but it is out of the ruleset range that must be
continuous.
.TP
.B RULEXDB_EPARM
The argument
.I rulexdb
or
.I rule_type
has an invalid value.
.TP
.B RULEXDB_EACCESS
The database is not opened for updating.
.SH SEE ALSO
.BR rulexdb_classify (3),
.BR rulexdb_close (3),
.BR rulexdb_dataset_name (3),
.BR rulexdb_discard_dictionary (3),
.BR rulexdb_discard_ruleset (3),
.BR rulexdb_fetch_rule (3),
.BR rulexdb_lexbase (3),
.BR rulexdb_load_ruleset (3),
.BR rulexdb_open (3),
.BR rulexdb_remove_item (3),
.BR rulexdb_remove_rule (3),
.BR rulexdb_remove_this_item (3),
.BR rulexdb_retrieve_item (3),
.BR rulexdb_search (3),
.BR rulexdb_seq (3),
.BR rulexdb_subscribe_item (3)
.SH AUTHOR
Igor B. Poretsky <poretsky@mlbox.ru>.
